package com.supermap.dataHandling.utils;

import java.util.ArrayList;
import java.util.List;

public class StringUtil {

    /**
     * 根据文件夹名称转换年月
     * @param dir
     * @return
     */
    public static List<String> parseYearAndMonth(String dir){
        List<String> dataInfo = new ArrayList<>();
        String s = dir.substring(0, 23);
        String substring = s.substring(s.length() - 8);
        String year = substring.substring(0,4);
        String monthTemp = substring.substring(substring.length() - 2);
        String month = null;
        String month_1 = null;
        if (monthTemp.substring(0,1).equals("0")){
            month = monthTemp.substring(monthTemp.length() - 1);
            Integer month1 = Integer.decode(month) - 1;
            month_1 = String.valueOf(month1);
            dataInfo.add(0,year);
            dataInfo.add(1,month);
            dataInfo.add(2,month_1);
        }else {
            Integer month1 = Integer.decode(monthTemp) - 1;
            month_1 = String.valueOf(month1);
            dataInfo.add(0,year);
            dataInfo.add(1,monthTemp);
            dataInfo.add(2,month_1);
        }

        return dataInfo;
    }

    /**
     * 数据处理地有四川省则去掉
     * @param dataName
     * @return
     */
    public static String parseDataName(String dataName){
        int i = dataName.lastIndexOf("四川省");

        dataName = dataName.substring(i + 3,dataName.length());

        return dataName;
    }
}
